package com.yt.server.messaging;

import java.io.Serializable;

/**
 * 发送的数据包(不完善)
 * 
 * @author Administrator
 */
public class Packet implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String id;

	private byte type;

	private byte state;

	private Header header;

	private String actionName;

	private String method;

	private Object[] params;

	// 当前所在活动区
	private String scopePath;

	private Object result;

	// 异常
	private Exception exception;

	public Packet() {
	}

	public Packet(Object result) {
		this.result = result;
	}

	public Packet(String id, byte type, byte state, Header header,
			String actionName, String method, Object[] params,
			String scopePath, Object result, Exception exception) {
		super();
		this.id = id;
		this.type = type;
		this.state = state;
		this.header = header;
		this.actionName = actionName;
		this.method = method;
		this.params = params;
		this.scopePath = scopePath;
		this.result = result;
		this.exception = exception;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public byte getType() {
		return type;
	}

	public void setType(byte type) {
		this.type = type;
	}

	public byte getState() {
		return state;
	}

	public void setState(byte state) {
		this.state = state;
	}

	public Header getHeader() {
		return header;
	}

	public void setHeader(Header header) {
		this.header = header;
	}

	public String getActionName() {
		return actionName;
	}

	public void setActionName(String actionName) {
		this.actionName = actionName;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public Object[] getParams() {
		return params;
	}

	public void setParams(Object[] params) {
		this.params = params;
	}

	public String getScopePath() {
		return scopePath;
	}

	public void setScopePath(String scopePath) {
		this.scopePath = scopePath;
	}

	public Object getResult() {
		return result;
	}

	public void setResult(Object result) {
		this.result = result;
	}

	public Exception getException() {
		return exception;
	}

	public void setException(Exception exception) {
		this.exception = exception;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((header == null) ? 0 : header.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + type;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Packet other = (Packet) obj;
		if (header == null) {
			if (other.header != null)
				return false;
		} else if (!header.equals(other.header))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (type != other.type)
			return false;
		return true;
	}
}